package com.tongji.showroom.view.twoD
{
	import com.tongji.showroom.events.FilterEvent;
	import com.tongji.showroom.utils.ConstVariableInventory;
	import com.tongji.showroom.view.SecondStepEditSceneComp;
	
	import flash.display.*;
	import flash.events.*;
	import flash.geom.Matrix;
	import flash.net.*;
	import flash.ui.Mouse;
	
	import mx.controls.Alert;
	import mx.core.IUIComponent;
	import mx.core.UIComponent;
	import mx.events.DragEvent;
	import mx.managers.DragManager;
	
	/**
	 * 这个类主要是为了对图片进行预上传，从而获取其bitmapData，顺便进行缩放
	 * @author chenzhongyuan
	 * 2011-7-28
	 */

	public class AddBitmap extends UIComponent 
	{	
		private var loader:Loader = new Loader();
		private var pointX:Number;
		private var pointY:Number;
		public var addBitmapData:BitmapData;

		
		public function AddBitmap(urls:String, X:Number, Y:Number):void
		{
			loader.load(new URLRequest(urls));
			loader.contentLoaderInfo.addEventListener(Event.COMPLETE,onComplete);
			pointX = X;
			pointY = Y;			
		}
		
		public function onComplete(e:Event):void
		{
			var addBitmap:Bitmap = Bitmap(loader.content);
			addBitmap.x =  ConstVariableInventory.X_SCALE * (pointX - addBitmap.width / 2);
			addBitmap.y =  ConstVariableInventory.Y_SCALE * (pointY - addBitmap.height / 2);	
			addBitmap.scaleX = ConstVariableInventory.X_SCALE;
			addBitmap.scaleY = ConstVariableInventory.Y_SCALE;	
			addBitmap.smoothing = true;
			addBitmapData = addBitmap.bitmapData;
			addChild(addBitmap);
		}
	}
}